//
//  RHPlantGroupBatchSelectCell.m
//  RuiHeApp
//
//  Created by Yan Chen on 2025/2/20.
//

#import "RHBatchPlantGroupSelectCell.h"
#import "KWTPlantGroupModel.h"
@interface RHBatchPlantGroupSelectCell()
@property (nonatomic ,strong) QMUILabel *plantGroupName;

@property (nonatomic ,strong) UIImageView *arrowImg;
@end
@implementation RHBatchPlantGroupSelectCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self setupUI];
    }
    return self;
}

-(void)setModel:(KWTPlantGroupModel *)model
{
    _model = model;
    self.plantGroupName.text = model.groupName;
    self.arrowImg.image = [UIImage imageNamed:model.isSelected?@"ugrade_select":@"ugrade_cancel"];

}

- (void)setupUI{

    [self setBackgroundColor:UIColor.clearColor];
    [self.contentView setBackgroundColor:UIColor.clearColor];
    
    kWeakSelf;
    UIView *bgView = [[UIView alloc] init];
    bgView.userInteractionEnabled = YES;
    [bgView setBackgroundColor:UIColor.whiteColor];
    [bgView.layer setCornerRadius:8];
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsMake(0, 15, 0, 15));
        make.height.offset(50);
    }];
    
    _plantGroupName = [[QMUILabel alloc] init];
    [_plantGroupName setFont:kSYSTEMFONT(14)];
    _plantGroupName.adjustsFontSizeToFitWidth = YES;
    _plantGroupName.minimumScaleFactor = 0.8;
    [_plantGroupName setTextColor:kCOLOR_HEX(@"#171A1D")];
    [bgView addSubview:_plantGroupName];
    
    _arrowImg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ugrade_cancel"]];
    [bgView addSubview:_arrowImg];
    [_arrowImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.offset(18);
        make.right.mas_offset(-15);
        make.centerY.mas_offset(0);
    }];
    
    
    UIView *line = kView;
    line.backgroundColor = kCOLOR_HEX_A(@"#7E868E",0.2);
    [bgView addSubview:line];
    
    [_plantGroupName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.equalTo(weakSelf.arrowImg.mas_right).offset(-5);
        make.centerY.mas_offset(0);
    }];
    
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.bottom.mas_offset(0);
        make.height.offset(1);
    }];

}

@end
